1 #include<iostream>
2 #include<fstream>
3 #include<stdio.h>
4 #include
"admin.h"
5 #include
"teacher.h"
6 #include
"student.h"
7
8 using
namespace std;
9
10 admin ad;

11
12 int
main()
13 {
14   fstream fs, f;
15
16   cout<<
"\n\nWelcome to Kendriya Vidyalaya Results";
17   
int opt=0, subopt=0, id, found=0;
18
19   student St;
20
21   
while(opt!=4)
22   {
23     cout<<
"\n\nMenu:\n1. Admin\n2. Teacher: Update Marks\n3. Student: Check Results\n4. Exit\n\nEnter option: ";
24     cin>>opt;
25
26     
switch(opt)
27     {
28       
case 1: cout<<"\n\nSub Menu:\n1. Add teacher\n2. Add student\n\nEnter option: ";
29               cin>>subopt;
30               
switch(subopt)
31               {
32                 
case 1: ad.addteacher();
33                         
break;
34                 
case 2: ad.addstudent();
35                         
break;
36                 
default: cout<<"\n\nInvalid choice";
37                          
break;
38               }
39               
break;
40
41       
case 2: cout<<"\n\nEnter teacher id: ";
42               cin>>id;
43
44               f.open(
"teacher.dat", ios::in);
45               teacher T; found =
0;
46
47               
while(!f.eof()&&found==0)
48               {
49                 f.read((
char*)&T, sizeof(T));
50
51                 
if(T.idcompare(id))
52                 { T.updateMarks();
53                   found=
1;
54                 }
55               }
56
57               
if(found == 0)
58                 cout<<
"\n\nInvalid ID";
59
60               f.close();
61               
break;
62
63       
case 3: cout<<"\n\nEnter student roll no: ";
64               cin>>id;
65
66               fs.open(
"student.dat", ios::in);
67               found =
0;
68
69               
while(!fs.eof()&&found==0)
70               {
71                 fs.read((
char*)&St, sizeof(St));
72
73                 
if(id == St.getroll())
74                 { St.display();
75                   found=
1;
76                 }
77               }
78
79               
if(found == 0)
80                 cout<<
"\n\nInvalid roll number";
81
82               fs.close();
83               
break;
84
85       
case 4: return 0;
86
87       
default: cout<<"\n\nInvalid choice";
88                
break;
89     }
90
91   }
92
93  
return 0;
94  }


Gõ tìm kiếm nhanh...